<#include "../inc/view.html"/>
<@view>
            <div class="row">
                <div class="col-sm-12">
                    <div class="row">
                        <div class="col-sm-6">
                            <ol class="breadcrumb">
                                <li>
                                    <b>系统</b>
                                </li>
                                <li class="active">
                                    用户
                                </li>
                            </ol>
                        </div>
                        <div class="col-sm-6">
                            <button class="btn-sm btn-success pull-right" onclick="contentLoadPage('/sysUser/add')"><i class="fa fa-plus"></i>新增</button>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-sm-12">
                          <form id="searchForm" name="searchForm" class="form-inline">
                              <input type="hidden" value="" name="pageNumber" id="pageNumber">
                              <div class="form-group-sm col-sm-3">
                                  <label>关键字</label>
                                  <input type="text" name="kwd" placeholder="请输入关键字查询" value="${kwd!}" class="form-control">
                              </div>
                              <div class="form-group-sm col-sm-3">
                                  <label>状态</label>
                                  <select class="form-control select2" name="status">
                                      <option value="">全部</option>
                                      <option value="1">启用</option>
                                      <option value="0">禁用</option>
                                  </select>
                                  <a class="btn btn-white" onclick="doSearch()"><i class="ti-search"></i>搜索</a>
                              </div>
                          </form>
                        </div>
                    </div>
                    <hr>
                    <div class="row">
                        <div class="col-sm-12">
                        <table class="table table-bordered m-0">
                            <thead>
                            <tr>
                                <th>#</th>
                                <th>姓名</th>
                                <th>性别</th>
                                <th>账号</th>
                                <th>手机</th>
                                <th>Email</th>
                                <th>最近登录</th>
                                <th>注册时间</th>
                                <th>状态</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <#assign sexList=['未知','男','女']/>
                            <#if page.list??>
                                <#list page.list as m>
                                        <tr>
                                            <td>${m_index+1}</td>
                                            <td>${m.realname!}</td>
                                            <td>${sexList[m.sex]}</td>
                                            <td>${m.account!}</td>
                                            <td>${m.mobile!}</td>
                                            <td>${m.email!}</td>
                                            <td>${m.last_login_time!}${m.lat_login_ip!}</td>
                                            <td>${m.create_datetime!}</td>
                                            <td><#if 1==m.status!0 ><span class="green">启用</span><#else><span class="red">禁用</span></#if></td>
                                            <td>
                                                <a href="javascript:void(0);" onclick="contentLoadPage('/sysUser/add/${m.id}')"><i class="fa fa-edit"></i>编辑</a>
                                                <a href="javascript:void(0);" onclick="delsysUser('${m.id}')"><i class="fa red fa-trash"></i>删除</a>
                                            </td>
                                        </tr>
                                </#list>
                            </#if>
                            </tbody>
                        </table>
                        </div>
                    </div>
                    <hr>
                    <div class="row">
                        <div class="col-sm-12">
                            <div id="page2" class="pull-right"></div>
                        </div>
                    </div>
                </div>
            </div>
</@view>
<script>
    function delsysUser(id_){
        layer.confirm('确定要删除此用户吗？', {
            btn: ['删除','取消'],shadeClose:true
        },function() {
            $.ajax({
                url: '/admin/sysUser/del/' + id_, success: function (json) {
                    if (json.code == RESULT_SUCCESS) {
                        contentLoadPage('/sysUser');
                        layer.closeAll();
                    } else {
                        if (json.msg)
                            layer.alert(json.msg, {icon: 5, title: '系统提示',time:3000,shadeClose:true});
                    }
                }
            });
        },function(){

        });
    }
    function doSearch(pageNum){
        if(pageNum){
            $("#pageNumber").val(pageNum);
        }
        contentLoadPage("/sysUser",$("#searchForm").serialize());
    }
    $(function(){
        $(".select2").select2();
        laypage({
            cont: 'page2',
            pages:${page.totalPage!1},
            curr:${page.pageNumber!1},
            jump: function (obj, first) {
                if (!first) {
                    doSearch(obj.curr);
                }
            }
        });
    });
</script>